package com.neusoft.mapper;

import com.neusoft.core.User;
import com.neusoft.core.UserDTO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

	@Select("select * from user where userId=#{userId} and password=#{password}")
	public User getUserByIdByPass(User user);
	
	@Select("select count(*) from user where userId=#{userId}")
	public int getUserById(String userId);

	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1,0,0,0)")
	public int saveUser(User user);

	@Update("update user set userType = #{businessId} where userId = #{userId}")
	public void updateUserTypeByUserId(String userId, Integer businessId);

	@Update("UPDATE user SET businessId = #{businessId} WHERE userId = #{userId}")
	public void updateBusinessIdByUserId(@Param("userId") String userId, @Param("businessId") Integer businessId);

	@Update("update user set userImg = #{userImg} where userId = #{userId}")
	int updateUserImg(@Param("userImg") String userImg, @Param("userId") String userId);

	@Update("update user set points = #{points} where userId = #{userId}")
	void updatePoints(@Param("points")int points, @Param("userId") String userId);

	@Select("select * from user where userId=#{userId}")
	public User getUserInfo(String userId);

	@Select("select walletId from user where userId=#{userId}")
	public Integer getWalletIdByUserId(String userId);

	@Update("update user set walletId = #{walletId} where userId = #{userId}")
	void updateWalletId(@Param("userId") String userId, @Param("walletId") int walletId);

	@Select("select userId from user where businessId=#{businessId}")
	public String getUserIdByBusinessId(Integer businessId);
}
